class Solution(object):
    def groupThePeople(self, groupSizes):
        """
        :type groupSizes: List[int]
        :rtype: List[List[int]]
        """
        d = {}
        for i, v in enumerate(groupSizes):
            d.setdefault(v, [])
            d[v].append(i)
        ans = []
        for k in d:
            i = 0
            while i < len(d[k]):
                ans.append(d[k][i:i+k])
                i += k
        return ans


class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        index = 0
        k = 1
        if len(nums) < 2:
            return len(nums)
        for i in range(1, len(nums)):
            if nums[index] < nums[i]:
                index += 1
                nums[index] = nums[i]
                k = 1
            elif k < 2:
                index += 1
                nums[index] = nums[i]
                k += 1
        return index+1
s = Solution()
a = [0,0,1,1,1,1,2,3,3]
l = print(s.removeDuplicates(a))
print(a[:l])




